<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;

	$this->Item['name'] = Zendvn_Filter_Filter::filterContent($this->Item['name']);
	$name 			= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	
		

	$options 		= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));	
	$status 		= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	
	$position 		= $this->formText('position',$this->Item['position'],array('class'=>'width-300 floatLeft' ));
	
	$content	 	= Zendvn_Filter_Filter::filterContent($this->Item['content']);
	$content		= $this->tinyMce('content',$content,array('style'=>"width: 100%; height: 350px;"));
	$content  		= '<div id="d_content" style="width:98%; float: left">' . $content . '</div>';
	
	$description	= Zendvn_Filter_Filter::filterContent($this->Item['description'], 'filter');
	$description	= $this->formTextarea('description', $description, array('class'=>'width-400 floatLeft', 'rows'=>8));
	
	$this->Item['html_descript'] = Zendvn_Filter_Filter::filterContent($this->Item['html_descript']);
	$html_descript 	= $this->formTextarea('html_descript',$this->Item['html_descript'],array('class'=>'width-400','rows'=>8));
	$this->Item['html_keyword'] = Zendvn_Filter_Filter::filterContent($this->Item['html_keyword']);
	$html_keyword 	= $this->formTextarea('html_keyword',$this->Item['html_keyword'],array('class'=>'width-400','rows'=>8));
	
	
	$picture	= $this->formFile('picture',array('class'=>'floatLeft' ));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
				'fileConfig'=>'doctor.ini'));
		// Start - Lấy hình ảnh của avatar
		$pictureConfig = $config->getConfig('doctor');
		$current_picture = '<div id="load-content-picture" class="clr width-150 center">';
		if(!empty($this->Item['picture'])){
			$pictureUrl = $pictureConfig['thumbUrl'] . '/' . $this->Item['picture'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'picture','file'=>$this->Item['picture']));
			$current_picture .= '<br>' . $this->cmsImage('picture',$pictureUrl,array('width'=>'175px'))
			. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-picture\',\'' . $removeLink . '\')">remove</a>';
		}
		$current_picture .= $this->formHidden('current_picture',$this->Item['picture'])
		. '</div>';
		$picture .=	$current_picture;
	}
	
	
	$arrTooltip = array(
						'name'=>"Họ và tên bác sỹ.",
						'picture'=>"Ảnh đại diện.",
						'description'=>"Mô tả",
						'position'=>"Vị trí làm việc hiện tại",
						'html_descript'=>"Mô tả ngắn phục vụ cho việc SEO",
						'html_keyword'=>"Từ khoá phục vụ cho việc SEO",
						'status'=>'Trạng thái',
						'd_content'=>"Nội dung giới thiệu",
						);
						
	if(count($arrTooltip)>0){
		foreach ($arrTooltip as $key => $val){
		   if($key=='d_content') $attribs = array('leftOffset'=>-305);
		   $formHelp  .= $this->cmsFormHelp('.form-table #' . $key, $this->translate($val), $attribs); 
		}
	}
	
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 		
	 	}
	 }
	 $arrRow = array(
					array('label'=>$this->translate('Họ và tên'),'input'=>$name),
	 				array('label'=>$this->translate('Ảnh đại diện'),'input'=>$picture),
	 				array('label'=>$this->translate('Chức vụ'),'input'=>$position),
	 				array('label'=>$this->translate('Mô tả'),'input'=>$description),
					array('label'=>$this->translate('Nội dung giới thiệu'),'input'=>$content),
					array('label'=>$this->translate('Mô tả nội dung SEO'),'input'=>$html_descript),
					array('label'=>$this->translate('Từ khoá SEO'),'input'=>$html_keyword),
					array('label'=>$this->translate('Trạng thái'),'input'=>$status),
					);
	$tdForm = $this->partialLoop('row.php',$arrRow);
	
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
        	<fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
        	</fieldset>  
        </div>
       
        <div class="clr"></div>
	</div>
</div>
